define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'resume/careerobjective/index' + location.search,
                    add_url: 'resume/careerobjective/add',
                    edit_url: 'resume/careerobjective/edit',
                    del_url: 'resume/careerobjective/del',
                    multi_url: 'resume/careerobjective/multi',
                    import_url: 'resume/careerobjective/import',
                    table: 'resume_career_objective',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'ObjectiveID',
                sortName: 'ObjectiveID',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'ObjectiveID', title: __('Objectiveid')},
                        {field: 'BasicinfoID', title: __('Basicinfoid')},
                        {field: 'AccommodationRequired', title: __('Accommodationrequired'), searchList: {"1":__('Accommodationrequired 1'),"0":__('Accommodationrequired 0')}, formatter: Table.api.formatter.normal},
                        {field: 'AvailabilityDay', title: __('Availabilityday'), searchList: {"7":__('Availabilityday 7'),"14":__('Availabilityday 14'),"30":__('Availabilityday 30'),"60":__('Availabilityday 60'),"90":__('Availabilityday 90'),"255":__('Availabilityday 255')}, formatter: Table.api.formatter.normal},
                        {field: 'ExpectedJobFunction', title: __('Expectedjobfunction'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'ExpectedJobIndustry', title: __('Expectedjobindustry'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'ExpectedJobLocation', title: __('Expectedjoblocation'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'ExpectedSalary', title: __('Expectedsalary')},
                        {field: 'CreatedTime', title: __('Createdtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'UpdatedTime', title: __('Updatedtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
